from jira import JIRA
import json
import io
import os
import sys
import subprocess

jira = JIRA('https://jira.ych.com',basic_auth=('zhang.zhe','tubaobao520zz'))
#issue = jira.search_issues('project = "DEP" AND status = "Deploying"',fields = 'comment,summary')
issue = jira.search_issues('project = "DEP" AND status = "COMPLETED" AND Assignee in ("Zhang zhe","Karthick")')

file = open("/root/script/output-new.txt", "w")
for item in issue:
    os.popen('date')
    print("write to out")
    print(item)
    file.write(str(item) + " ")
    file.write(str(item.fields.summary) + "\n")
file.close()

for item in issue:
    print("write to comments")
    print(item)
    os.popen('/root/script/jira-new.sh > /jira-new.sh.log')
    #jira.add_comment(item,'Deployment has been done')
    #os.popen('date')
